package me.ianhe.other.arithmetic.pat.b1037;

import java.util.Scanner;

/**
 * @author iHelin
 * @since 2018/3/6 10:09
 */
public class Main {

    private static final int[] W = {17 * 29, 29, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] p = in.next().split("\\.");
        String[] a = in.next().split("\\.");
        int[] P = {Integer.parseInt(p[0]), Integer.parseInt(p[1]), Integer.parseInt(p[2])};
        int[] A = {Integer.parseInt(a[0]), Integer.parseInt(a[1]), Integer.parseInt(a[2])};
        int ta = A[0] * W[0] + A[1] * W[1] + A[2] * W[2];
        int tp = P[0] * W[0] + P[1] * W[1] + P[2] * W[2];
        int t = ta - tp;
        if (ta < tp) {
            System.out.print("-");
            t = -t;
        }
        System.out.println(t / W[0] + "." + t % W[0] / W[1] + "." + t % W[0] % W[1] / W[2]);
    }
}
